with v8.Class_String;
limited with v8.Class_Heap_Graph_Edge;
package v8.Class_Heap_Graph_Node is
   type Heap_Graph_Node (<>) is tagged limited private;
   type Pointer is access all Heap_Graph_Node;
   type Readonly_Pointer is access constant Heap_Graph_Node;
   -- represents a node in a heap graph.

   function Get_Type (this : Heap_Graph_Node) return Heap_Graph_Node_Type.Enum;
   -- Returns node type (see HeapGraphNode::Type)

   function Get_Name (this : Heap_Graph_Node) return v8.Class_String.Pointer;
   -- Returns node name. Depending on node's type this can be the name
   -- of the constructor (for objects), the name of the function (for
   -- closures), string value, or an empty string (for compiled code).

   function Get_Id (this : Heap_Graph_Node) return uint64_t;
   -- Returns node id. For the same heap object, the id remains the same
   -- across all snapshots.

   function Get_Self_Size (this : Heap_Graph_Node) return int;
   -- Returns node's own size, in bytes.

   function Get_Retained_Size (this : Heap_Graph_Node; exact : bool) return int;
   -- Returns node's retained size, in bytes. That is, self + sizes of
   -- the objects that are reachable only from this object. In other
   -- words, the size of memory that will be reclaimed having this node
   -- collected.
   --
   -- Exact retained size calculation has O(N) (number of nodes)
   -- computational complexity, while approximate has O(1). It is
   -- assumed that initially heap profiling tools provide approximate
   -- sizes for all nodes, and then exact sizes are calculated for the
   -- most 'interesting' nodes.

   function Get_Children_Count (this : Heap_Graph_Node) return int;
   -- Returns child nodes count of the node.

   function Get_Child
     (this  : Heap_Graph_Node;
      index : int
     ) return v8.Class_Heap_Graph_Edge.Readonly_Pointer;
   -- Retrieves a child by index.

   function Get_Retainers_Count (this : Heap_Graph_Node) return int;
   -- Returns retainer nodes count of the node.

   function Get_Retainer
     (this  : Heap_Graph_Node;
      index : int
     ) return v8.Class_Heap_Graph_Edge.Readonly_Pointer;
   -- Returns a retainer by index.

   function Get_Dominator_Node (this : Heap_Graph_Node) return Readonly_Pointer;
   -- Returns a dominator node. This is the node that participates in every
   -- path from the snapshot root to the current node.


private

   type Heap_Graph_Node is tagged limited null record;


   pragma Import (CPP, Get_Type, "_ZNK2v813HeapGraphNode7GetTypeEv");
   pragma Import (CPP, Get_Name, "_ZNK2v813HeapGraphNode7GetNameEv");
   pragma Import (CPP, Get_Id, "_ZNK2v813HeapGraphNode5GetIdEv");
   pragma Import (CPP, Get_Self_Size, "_ZNK2v813HeapGraphNode11GetSelfSizeEv");
   pragma Import (CPP, Get_Retained_Size, "_ZNK2v813HeapGraphNode15GetRetainedSizeEb");
   pragma Import (CPP, Get_Children_Count, "_ZNK2v813HeapGraphNode16GetChildrenCountEv");
   pragma Import (CPP, Get_Child, "_ZNK2v813HeapGraphNode8GetChildEi");
   pragma Import (CPP, Get_Retainers_Count, "_ZNK2v813HeapGraphNode17GetRetainersCountEv");
   pragma Import (CPP, Get_Retainer, "_ZNK2v813HeapGraphNode11GetRetainerEi");
   pragma Import (CPP, Get_Dominator_Node, "_ZNK2v813HeapGraphNode16GetDominatorNodeEv");
end v8.Class_Heap_Graph_Node;
